<template>
    <div :class="sizeClassName" class="mmv-topic-card">
        <mmv-link :to="`/topicDeatil/${topic.id}`" class="mmv-topic-card__link" target="_blank">
            <div class="mmv-topic-card__cover">
                <img :src="topic.cover" class="mmv-topic-card__img" />
            </div>
        </mmv-link>
        <div class="mmv-topic-card__info">
            <mmv-link :to="`/topicDeatil/${topic.id}`" class="mmv-topic-card__link" target="_blank">
                <p class="mmv-topic-card__name">{{topic.name}}</p>
            </mmv-link>
            <p class="mmv-topic-card__desc" v-if="topic.desc">{{topic.desc}}</p>
        </div>
    </div>
</template>

<script>
export default {
    name: "mmv-topic-card",
    props: {
        topic: {
            type: Object,
            required: true,
        },
        size: {
            type: String,
            default: "md",
        },
    },
    computed: {
        sizeClassName() {
            const className = {
                sm: "mmv-topic-card-sm",
                md: "mmv-topic-card-md",
                lg: "mmv-topic-card-lg",
            };
            return className[this.size] || "mmv-topic-card-md";
        },
    },
};
</script>

<style lang="less">
.mmv-topic-card {
    display: flex;
    align-items: center;
    &__cover {
        display: inline-block;
        flex-shrink: 0;
        position: relative;
        overflow: hidden;
        border-radius: 8px;
        border: 1px solid #ebebeb;
    }
    &-sm &__cover {
        width: 50px;
        height: 50px;
    }
    &-md &__cover {
        width: 60px;
        height: 60px;
    }
    &-lg &__cover {
        width: 80px;
        height: 80px;
    }
    &__img {
        width: 100%;
        height: 100%;
        border-radius: 8px;
    }
    &__link {
        color: #333;
        display: flex;
        align-items: center;
    }
    & a&__link:hover {
        color: #00c3ff;
    }
    &__info {
        display: inline-block;
        margin-left: 20px;
        flex-grow: 1;
        overflow: hidden;
    }
    &-sm &__info {
        margin-left: 10px;
    }
    &__name {
        position: relative;
        line-height: 20px;
    }
    &-lg &__name {
        font-size: 16px;
    }
    &__desc {
        color: #999;
        font-size: 12px;
        line-height: 18px;
    }
    &-lg &__desc {
        font-size: 14px;
        line-height: 18px;
        margin-top: 6px;
    }
    .mmv-follow-button.mmv-follow-button-lg {
        width: 130px;
        height: 36px;
        line-height: 34px;
        font-weight: 600;
    }
}
</style>